package com.zhongke.DKYCboot.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhongke.DKYCboot.bean.PersonCar;
import com.zhongke.DKYCboot.mapper.PersonCarMapper;
import com.zhongke.DKYCboot.service.PersonCarService;
import com.zhongke.DKYCboot.util.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.relational.core.sql.In;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonCarServiceImpl implements PersonCarService {
    @Autowired
    private PersonCarMapper personCarMapper;

    @Override
    public Msg insertPersonCar(PersonCar personCar) {
        int flag = personCarMapper.insertPersonCar(personCar);
        if(flag > 0){
            return Msg.success("成功");
        }else {
            return Msg.fail("失败");
        }
    }

    @Override
    public Msg selectPersonCar(PersonCar personCar, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PersonCar> personCarList = personCarMapper.selectPersonCar(personCar);
        PageInfo<PersonCar> pageInfo = new PageInfo<>(personCarList);
        return Msg.success(pageInfo);
    }

    @Override
    public Msg updatePersonCar(PersonCar personCar) {
        int flag = personCarMapper.updatePersonCar(personCar);
        if(flag > 0){
            return Msg.success("成功");
        }else {
            return Msg.fail("失败");
        }
    }
}
